﻿package com.wandian.util
{
	import com.greensock.TweenLite;
	import com.greensock.easing.Linear;
	import com.wandian.data.GameData;

	/**
	* @author long
	* @QQ 108232706
	* @version 1.0
	*/
	public class NumRollText extends Object
	{
		private var _nType:int=0;
		protected var _textObj:Object;
		protected var _rollTime:Number=1;
		protected var _showSign:String="";
		private var _global:GameData;
		protected var _num:Number=0;
		protected var _curNum:Number;

		public function NumRollText(textObj:Object, showNum:Number=0, nType:int=0, showSign:String="")
		{
			this._global=GameData.getInstance();
			this._textObj=textObj;
			this._nType=nType;
			this._num=this.curNum=showNum;
//			this._num=_loc_5;
			this._showSign=showSign;
			return;
		}

		public function get num():Number
		{
			return this._num;
		}

		public function set num(toNum:Number):void
		{
			if (this._num == toNum)
			{
				return;
			}
			this._num=toNum;
			TweenLite.to(this, this._rollTime, {curNum: this._num, ease: Linear.easeNone});
			return;
		}

		public function get curNum():Number
		{
			return this._curNum;
		}

		public function set curNum(numValue:Number):void
		{
			numValue=CLZMath.precision(numValue, 0);
			this._curNum=numValue;
			switch (this._nType)
			{
				case 0:
				{
					this._textObj.text=TextUtils.getDotTxt(this.curNum) + " " + this._showSign;
					break;
				}
				case 1:
				{
					this._textObj.text="" + this.curNum + " " + this._showSign;
					break;
				}
				case 2:
				{
					this._textObj.text="" + this._global.counstK(this.curNum) + " " + this._showSign;
					break;
				}
				case 3:
				{
					if (this.curNum >= 1000000)
					{
						this._textObj.text="" + this._global.counstK(this.curNum) + " " + this._showSign;
					}
					else
					{
						this._textObj.text=TextUtils.getDotTxt(this.curNum) + " " + this._showSign;
					}
					break;
				}
				case 5:
				{
					this._textObj.text=this.curNum;
					break;
				}
				default:
				{
					break;
				}
			}
			return;
		}

	}
}
